<?php

class Bookshop extends Article {

	var $id_bookshop;
	var $title;
	var $description;
	
	var $address;
	var $phone;
	var $url;
	var $specs;
	var $votes;
	
	/////////////////////////////////////////////////
	// Static member methods
	
	function Bookshop($id_bookshop = -1, $complete = false) {
		global $site;
		$this->_table_name = "articles";
		$this->_site = $site;
		$this->_object_type = "bookshop";
		$this->_db = new mysqlconn(HOST,USER,PASS,DB);
		$this->_meta_fields = array("address","phone","url");
		$this->specs = array();
		$this->votes = array();
		$this->_alias_fields = array("id_article" => "id_bookshop", "title" => "title", "content" => "description");

		if ($id_bookshop != -1) {
			$this->load($id_bookshop);
		}
	}
	
	function create($title, $description) {
		$bookshop = new Bookshop();
		$bookshop->title = $title;
		$bookshop->description = $description;		
		return $bookshop->save();
	}

	//////////////////////////////////////////////////////////////////////////////
	// Instance member methods
	
	function get_books() {
		return $this->get_membresies_by_type("book");
	}
	
	function count_books() {
		$books = $this->get_books();
		return count();
	}
	
	function get_specializations() {
		return $this->get_parent_membresies_by_type("specialization");
	}
	
	function get_regions() {
		return $this->get_parent_membresies_by_type("region");
	}
	
	///////////////////////////////////////////////////////////////////////////////
	// Polymorphism methods
	function get_instance($id_instance) {
		return new Bookshop($id_instance);
	}
		
}

?>